{% extends 'base.html' %}
{% load static %}

{% block content %}
  <form id="nf_form" class="form" method="post" enctype="multipart/form-data">
    {% csrf_token %}
    <div class="form-group">
      <label class="control-label" for="id_title">{{ nf_form.title.label }}</label>
      {{ nf_form.title }}
    </div>
    <div class="form-group">
      <label class="control-label" for="id_content">{{ nf_form.content.label }}</label>
      {{ nf_form.content }}
    </div>
    <div class="form-group">
      <label class="control-label" for="id_grade">{{ nf_form.grade.label }}</label>
      {{ nf_form.grade }}
    </div>
    <div class="form-group">
      <label class="control-label" for="id_file">{{ file_form.file.label }}</label>
      {{ file_form.file }}
      <span class="help-block">{{ file_form.file.help_text }}</span>
    </div>
    <div class="form-group">
      {{ nf_form.delete }}
    </div>
    <div class="btn-group">
      {% if notification %}
        <a class="btn btn-primary" href="{% url 'detail' notification.pk %}"><span class="glyphicon glyphicon-remove"></span> Cancel</a>
      {% else %}
        <a class="btn btn-primary" href="{% url 'view' %}"><span class="glyphicon glyphicon-remove"></span> Cancel</a>
      {% endif %}
      <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Submit</button>
      {% if edit %}
        <button type="button" class="btn btn-primary" onclick="nf_delete();"><span class="glyphicon glyphicon-trash"></span> Delete</button>
      {% endif %}
    </div>
  </form>
{% endblock %}

{% block script %}
  <script type="text/javascript">
    function nf_delete(){
        var form = document.getElementById('nf_form');
        form.delete.value = true;
        form.submit();
      }
  </script>
{% endblock %}